<template>
    <div class="basicinformationcompleted">
        <div class="yanhua">
            <canvas class="yanhua" ref="confettiCanvas"></canvas>
        </div>
        <div class="basicinformationcompletedbg">
            <img class="basicinformationcompletedbg-img" v-if="this.$route.query.id == 2"
                src="@/assets/images/red/complete_fill.jpg" alt="">
            <img class="basicinformationcompletedbg-img" v-if="this.$route.query.id == 1"
                src="@/assets/images/red/complete_fill_1.jpg" alt="">
        </div>
        <div class="basicinformationcompletedtext">
            <div class="basicinformationcompletedtext-new"><span> {{ moneyinfo.withdrawalMoney }} </span><span
                    class="yuan">元</span></div>
            <div class="basicinformationcompletedtext-old"><span> {{ moneyinfo.snatchMoney }} </span><span
                    class="yuan">元</span></div>
        </div>
        <div class="basicinformationcompletedbtn" @click="gosce">
            <img class="basicinformationcompletedbtn-img" src="@/assets/images/red/basicinformationcompletedbtn.png" alt="">
        </div>
    </div>
</template>
<script>
import confetti from 'canvas-confetti';
import { getredpacket, addpacketstep, addburyingpoint } from '@/api/http.js'
export default {
    data() {
        return {
            isshow: true,
            moneyinfo: {},
        }
    },
    methods: {
        startConfetti() {
            confetti.create(this.$refs.confettiCanvas, {
                resize: true,
                useWorker: true,
            })({ particleCount: 200, spread: 200 });
        },
        getgetredpacket() {
            getredpacket().then(res => {
                this.moneyinfo = res.data
                console.log(res)
            })
        },
        gosce() {
            if (this.$route.query.id == 1) {
                let obj = { buriedPointName: '完成筛查', function: '2', module: '3', redirectPage: '筛查结果详情页', section: '5', orgNo: '' }
                addburyingpoint(obj).then(res => {

                    console.log(res)
                })
                this.$router.push({
                    path: '/' + this.$route.query.path
                })

            } else if (this.$route.query.id == 2) {
                let obj = { buriedPointName: '信息填写完成查看金额', function: '3', module: '2', redirectPage: '进入筛查题组页', section: '4', orgNo: '' }
                addburyingpoint(obj).then(res => {

                    console.log(res)
                })
                console.log(JSON.parse(localStorage.getItem('userinfo')))
                this.$router.push({
                    path: '/sce',
                    query: JSON.parse(localStorage.getItem('userinfo'))
                })
            }
        }
    },
    created() {
        let url = ''

        url = encodeURIComponent(this.$route.name + '?id=' + this.$route.query.id + '&path=' + this.$route.query.path)
        addpacketstep(url).then(res => {
            console.log(res)
        })
        setTimeout(() => {
            this.getgetredpacket()
        })
    },
    mounted() {
        this.startConfetti()
    }
}
</script>
<style>
.basicinformationcompleted {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.yanhua {
    width: 100%;
    height: 100%;
    position: absolute;
}

.basicinformationcompletedbg {
    /* position: absolute; */
    width: 100%;
    height: 100%;
}

.basicinformationcompletedbg-img {
    width: 100%;
    height: 100%;
}

.basicinformationcompletedbtn {
    margin: auto;
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 196px;
    height: 63px;
}

.basicinformationcompletedbtn-img {
    width: 100%;
    height: 100%;
}

.basicinformationcompletedtext {
    position: absolute;
    top: 40%;
    width: 375px;
    text-align: center;
    font-weight: bold;
    font-size: 50px;
    margin-left: 50px;
    color: #fd524b;
}

.basicinformationcompletedtext-new {
    position: relative;
    top: -19px;

    /* margin-bottom: 30px; */
}

.basicinformationcompletedtext-old {
    margin-top: 10%;
    /* 40px */
}

.yuan {
    font-weight: bold;
    font-size: 28px;
}</style>